package com.acwing.partition20;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

/**
 * @author `RKC`
 * @date 2022/5/5 16:55
 */
public class AC1959奶牛芭蕾 {

    private static final int INF = 0x3f3f3f3f;
    private static final int[][] dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    private static int[][] pos = {{0, 1}, {1, 1}, {0, 0}, {1, 0}};
    private static Map<String, Integer> id = new HashMap<>(4);
    private static Map<Character, Integer> turn = new HashMap<>(4);
    private static int n;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    static {
        id.put("FL", 0); id.put("FR", 1); id.put("RL", 2); id.put("RR", 3);
        turn.put('F', 0); turn.put('B', 2); turn.put('L', 3); turn.put('R', 1);
    }

    public static void main(String[] args) throws IOException {
        //默认初始面向的方向是北
        int minx = INF, maxx = -INF, miny = INF, maxy = -INF, d = 0;
        n = nextInt();
        for (int i = 0; i < n; i++) {
            String s = next();
            //取出当前指令操作的对象和操作的指令
            int t = id.get(s.substring(0, 2));
            char opt = s.charAt(2);
            if (opt == 'P') {
                //以key为轴顺时针旋转90°
                for (int j = 0; j < 4; j++) {
                    if (t == j) continue;
                    //以t为轴，将j顺时针旋转90°
                    rotate(t, j);
                }
                d = (d + 1) % 4;
            } else {
                int k = (d + turn.get(opt)) % 4;
                pos[t][0] += dirs[k][0];
                pos[t][1] += dirs[k][1];
            }
            //判断是否合法，也即是判断是否会出现踩到同一个地方
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < j; k++) {
                    if (pos[j][0] == pos[k][0] && pos[j][1] == pos[k][1]) {
                        writer.println("-1");
                        writer.flush();
                        return;
                    }
                }
            }
            for (int j = 0; j < 4; j++) {
                minx = Math.min(minx, pos[j][0]); miny = Math.min(miny, pos[j][1]);
                maxx = Math.max(maxx, pos[j][0]); maxy = Math.max(maxy, pos[j][1]);
            }
        }
        writer.println((maxx - minx + 1) * (maxy - miny + 1));
        writer.flush();
    }

    private static void rotate(int a, int b) {
        pos[b][0] -= pos[a][0];
        pos[b][1] -= pos[a][1];
        int x = pos[b][1], y = -pos[b][0];
        pos[b][0] = x + pos[a][0];
        pos[b][1] = y + pos[a][1];
    }

    private static String next() throws IOException {
        tokenizer.nextToken();
        return tokenizer.sval;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
